package ipmsg.etc;

import java.text.SimpleDateFormat;
import java.util.Date;













public class GlobalUtility
{
  public static boolean isIP(String ip)
  {
    String[] content = ip.split("\\.");
    if (content.length != 4) return false;
    try
    {
      for (int i = 0; i < 4; i++) {
        int j = Integer.parseInt(content[i]);
        if ((j > 255) || (j < 0)) return false;
      }
    } catch (NumberFormatException e) {
      return false;
    }
    return true;
  }
  



  public static String getTime()
  {
    Date curTime = new Date();
    String sss = new String("yyyy-MM-dd  kk:mm:ss");
    SimpleDateFormat sdf = new SimpleDateFormat(sss);
    String res = sdf.format(curTime);
    return res;
  }
  



  public static int getNumber(String number)
  {
    try
    {
      return new Integer(number).intValue();
    }
    catch (NumberFormatException e) {}
    return -1;
  }
}
